1. Field of the Invention
The present invention relates generally to computer systems, and in particular, to a computer system which executes object-oriented code.
2. Discussion of Related Art
Many individuals and organizations in the computer and communications industries tout the Internet as the fastest growing market on the planet. In the 1990s, the number of users of the Internet appears to be growing exponentially with no end in sight. In June of 1995, an estimated 6,642,000 hosts were connected to the Internet; this represented an increase from an estimated 4,852,000 hosts in January, 1995. The number of hosts appears to be growing at around 75% per year. Among the hosts, there were approximately 120,000 networks and over 27,000 web servers. The number of web servers appears to be approximately doubling every 53 days.
In July 1995, with over 1,000,000 active Internet users, over 12,505 usenet news groups, and over 10,000,000 usenet readers, the Internet appears to be destined to explode into a very large market for a wide variety of information and multimedia services.
In addition, to the public carrier network or Internet, many corporations and other businesses are shifting their internal information systems onto an intranet as a way of more effectively sharing information within a corporate or private network. The basic infrastructure for an intranet is an internal network connecting servers and desktops, which may or may not be connected to the Internet through a firewall. These intranets provide services to desktops via standard open network protocols which are well established in the industry. Intranets provide many benefits to the enterprises which employ them, such as simplified internal information management and improved internal communication using the browser paradigm. Integrating Internet technologies with a company's enterprise infrastructure and legacy systems also leverages existing technology investment for the party employing an intranet. As discussed above, intranets and the Internet are closely related, with intranets being used for internal and secure communications within the business and the Internet being used for external transactions between the business and the outside world. For the purposes of this document, the term "networks" includes both the Internet and intranets. However, the distinction between the Internet and an intranet should be born in mind where applicable.
In 1990, programmers at Sun Microsystems wrote a universal programming language. This language was eventually named the JAVA programming language. (JAVA is a trademark of Sun Microsystems of Mountain View, Calif.) The JAVA programming language resulted from programming efforts which initially were intended to be coded in the C++ programming language; therefore, the JAVA programming language has many commonalties with the C++ programming language. However, the JAVA programming language is a simple, object-oriented, distributed, interpreted yet high performance, robust yet safe, secure, dynamic, architecture neutral, portable, and multi-threaded language.
The JAVA programming language has emerged as the programming language of choice for the Internet as many large hardware and software companies have licensed it from Sun Microsystems. The JAVA programming language and environment is designed to solve a number of problems in modern programming practice. The JAVA programming language omits many rarely used, poorly understood, and confusing features of the C++ programming language. These omitted features primarily consist of operator overloading, multiple inheritance, and extensive automatic coercions. The JAVA programming language includes automatic garbage collection that simplifies the task of programming because it is no longer necessary to allocate and free memory as in the C programming language. The JAVA programming language restricts the use of pointers as defined in the C programming language, and instead has true arrays in which array bounds are explicitly checked, thereby eliminating vulnerability to many viruses and nasty bugs. The JAVA programming language includes objective-C interfaces and specific exception handlers.
The JAVA programming language has an extensive library of routines for coping easily with TCP/IP protocol (Transmission Control Protocol based on Internet protocol), HTTP (Hypertext Transfer Protocol) and FTP (File Transfer Protocol). The JAVA programming language is intended to be used in networked/distributed environments. The JAVA programming language enabled the construction of virus-free, tamper-free systems. The authentication techniques are based on public-key encryption.
As previously described, the JAVA programming language is an object oriented language. FIG. 1 is a block diagram which illustrates the processing of a conventional object oriented instruction, INSTRUCTION [METHOD.sub.-- NO, NO.sub.-- ARGS]. FIG. 1 illustrates operand stack 10, objects 20A and 20B, method vectors 30A and 30B and code vectors 40A and 40B. Objects 20A and 20b, method vectors 30A and 30B, and code vectors 40A and 40B are stored at predetermined addresses in a program memory (not shown). Object oriented computer programs, such as those programs written in the JAVA programming language, typically include a number of super classes and sub-classes. In the described example, object 20A forms a super class, while object 20B forms a sub-class.
The instruction, INSTRUCTION [METHOD.sub.-- NO, NO.sub.-- ARGS], is provided to an execution unit (not shown). This instruction is capable of accessing any one of four associated methods, METHOD 0, METHOD 1, METHOD 2 and METHOD 3. The variable, METHOD.sub.-- NO, has a value of 0, 1, 2 or 3 to identify the method to be accessed by the instruction. For example, when the variable METHOD.sub.-- NO has a value of 1, the execution unit accesses code associated with METHOD 1.
The instruction also includes a variable, NO.sub.-- ARGS, which identifies the number of arguments associated with the instruction. The arguments associated with the instruction are stored at the top of operand stack 10. In the described example, the variable NO.sub.-- ARGS has a value of 2 to indicate that there are two arguments (i.e., ARGUMENT #1 and ARGUMENT #2) associated with the instruction stored in operand stack 10. A pointer to an object header is stored immediately below the arguments in operand stack 10. This pointer identifies the address of an object which is associated with the instruction.
The execution unit determines the location of the pointer to the object header within operand stack 10 from the variable NO.sub.-- ARGS, and retrieves this pointer from operand stack 10. Thus, if the variable NO.sub.-- ARGS is equal to 2, the execution unit retrieves the pointer to the object header from the third entry down from the top of operand stack 10. In the described example, the pointer to the object header has a value of 1000. In response, the execution unit accesses address 1000 within the program memory. Address 1000 corresponds with object 20A. Object 20A includes an object header and object data which defines object 20A. In the present example, the object header of object 20A has a value of 2000. The object header is also referred to as a class pointer.
The execution unit accesses the value of the object header from address 1000 of the program memory. The execution unit then adds the value of the object header and the value of the variable METHOD.sub.-- NO. The resulting value is a method descriptor pointer (or method vector entry) which is used to access method vector 30A. That is, the execution unit accesses the address which is identified by the method descriptor pointer value. For example, if the variable METHOD.sub.-- NO has a value of 1, the execution unit generates a method descriptor pointer having a value of 2001. In this case, the execution unit accesses the method pointer stored at address 2001 of the program memory (i.e., METHOD POINTER 1). In the described example, METHOD POINTER 1 has a value of 6000.
The execution unit then accesses code which is stored at the address identified by the value of the accessed method pointer. For example, if METHOD POINTER 1 is accessed, the execution unit accesses code which is stored at address 6000 of the program memory (i.e., CODE FOR METHOD 1).
By selecting the variable METHOD.sub.-- NO to have values of 0, 2 and 3, the execution unit accesses CODE FOR METHOD 0 at address 3000, CODE FOR METHOD 2 at address 5000, and CODE FOR METHOD 3 at address 6000, respectively.
If the pointer to the object header stored in operand stack 10 has a value of 1500, then the execution unit accesses object 20B. The object header for object 20B has a value of 2500. Thus, if the METHOD.sub.-- NO has a value of 1, the method descriptor pointer has a value of 2501. As a result, the execution unit accesses METHOD POINTER 1 at address 2501 of the program memory. In the described example, METHOD POINTER 1 has a value of 4000. Consequently, the execution unit accesses the CODE FOR METHOD 1 at address 4000 of the program memory.
Thus, objects 20A and 20B are able to share the same code in the program memory. As is well known in the art, this is one of the advantages of an object oriented program. Objects 20A and 20B can also access unique code within the program memory. For example, object 20A can access code located at addresses 3000, 5000 and 6000 of the program memory, while object 20B can access code located at address 7000 of the program memory.
Although different objects can share the same code in the program memory, the execution unit must undergo two levels of indirection to accomplish this code sharing. That is, the execution unit must generate and use the method descriptor pointer to direct access to the appropriate method pointer, and the execution unit must retrieve and use the method pointer to direct access to the appropriate code. Yet another level of indirection may be introduced if the accessed code directs the execution unit to code which is located at another address in the program memory.
Each level of indirection requires additional processing time within the execution unit. Thus, as the levels of indirection increase, the time required for the execution unit to complete the execution of the instruction also increases. In certain object oriented programs, the time required to execute the code is relatively short. As a result, the additional processing time introduced by the levels of indirection can be as much as 40% of the entire time required to execute the instruction.
It would therefore be desirable to have a method for accessing object oriented code which reduces the levels of indirection required to execute an object oriented instruction.